// QuestionsCollectedController.java
package com.scuec.groupfive.Controller;

import com.scuec.groupfive.entity.User;
import com.scuec.groupfive.service.QuestionsCollectedService;
import com.scuec.groupfive.vo.QuestionsCollectedVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/api/questions/collected")
public class QuestionsCollectedController {

    @Autowired
    private QuestionsCollectedService questionsCollectedService;

    @GetMapping
    public Map<String, Object> getCollectedQuestions(
            @RequestParam("userId") Integer userId,
            @RequestParam(value = "subjectId", required = false) Integer subjectId,
            @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
            @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
        return questionsCollectedService.getCollectedQuestions(userId, subjectId, pageNum, pageSize);
    }

    @GetMapping("/searchUser")
    public User searchUser(@RequestParam("username") String username) {
        return questionsCollectedService.searchUser(username);
    }
}